{% extends 'base.html' %}

{% block body %}

<h2>Home</h2>

{% if session.logged_in %}


    <form action="indexselection" method="get">
    Start Time: <input type="date" name="date_start" />
    End Time: <input type="date" name="date_end" /><br/><br/>
    Targets: <input id="input1" name="targets" readonly="readonly" onfocus="f()" style="width:400px"><br/><br>
    <div id="div1" onmouseleave="l()">
    {% for target in fulltargets %}
        <input type="checkbox" name="target" value="{{ target }}" onclick="c()">{{ target }}<br/>
    {% endfor %}
    </div>
    KeyWords: <input type="text" name="keywords" /><br/><br/>
    <input type="submit" name="search" value="search" />
    </form>
    <br/>




    <p><a href="{{ url_for('new') }}">new</a></p>

    <ul class=entries>
    {% for entry in entries %}
        <li><h3><a href="/detail?id={{ entry.id }}">{{ entry.title }}</a></h3>

        <p>
        <a class=createtime>{{ entry.createtime }}</a>

        {% for target in targetlists[entry.id] %}
            <a class=target href="/targetindex?target_name={{ target }}">&lt;{{ target }}&gt;</a>
        {% endfor %}
        </p>

        <p class=text>{{ entry.text[:100]|safe }}</p>

        <a href="/edit?id={{ entry.id }}">edit</a>
        <a href="javascript:void(0)" onclick="delete_confirm({{ entry.id }})">delete</a>
        </li>
    {% else %}
        <li><em>Unbelievable. No entries here so far</em>
        </li>
    {% endfor %}
    </ul>

{% else %}
    <p class=error>
    <strong>Error:</strong>
    log in please!!
    </p>

{% endif %}

{% endblock %}
